//
//  ViewController.m
//  gundongtiao
//
//  Created by mac on 16-3-3.
//  Copyright (c) 2016年 limengjie. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UILabel *imagID;
@property (weak, nonatomic) IBOutlet UIImageView *myImag;

- (IBAction)shang;
- (IBAction)xia;

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)shang {
    NSString *myImageID = self.imagID.text;
    NSString *imageName = [[NSString alloc]init];
    NSString *idOFstr = [myImageID substringToIndex:2];
    NSLog(@"%@",idOFstr);
    int idOFint = [idOFstr intValue];
    if (idOFint == 1) {
        UIAlertView *msg =[[UIAlertView alloc]initWithTitle:@"提示" message:@"这已经是第一张了" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil, nil];
        [msg show];
    }
    else{
        idOFint --;
        if (idOFint < 10) {
            idOFstr = [NSString stringWithFormat:@"0%d/24",idOFint];
        }else{
            idOFstr = [NSString stringWithFormat:@"%d/24",idOFint];
        }
        imageName = [NSString stringWithFormat:@"%d.jpg",idOFint];
        self.imagID.text = idOFstr;
        self.myImag.image = [UIImage imageNamed:imageName];
    }
}

- (IBAction)xia {
    NSString *myImageID = self.imagID.text;
    NSString *imageName = [[NSString alloc]init];
    NSString *idOFstr = [myImageID substringToIndex:2];
    NSLog(@"%@",idOFstr);
    int idOFint = [idOFstr intValue];
    if (idOFint == 24) {
        UIAlertView *msg =[[UIAlertView alloc]initWithTitle:@"提示" message:@"这已经是最后一张了" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil, nil];
        [msg show];
    }
    else{
        idOFint ++;
        if (idOFint < 10) {
            idOFstr = [NSString stringWithFormat:@"0%d/24",idOFint];
        }else{
            idOFstr = [NSString stringWithFormat:@"%d/24",idOFint];
        }
        imageName = [NSString stringWithFormat:@"%d.jpg",idOFint];
        self.imagID.text = idOFstr;
        self.myImag.image = [UIImage imageNamed:imageName];
    }

}
@end
